package leetcode.singles;

/**
 * @Author: Liu Yue
 * @Descripition:
 *
 * 优点：写法优雅
 *       利用java本身语法特点，内部类；
 * 缺点：反射破坏
 * @Date; Create in 2020/2/26 21:34
 **/
public class LazyStaticinnerClassSingle {

    private LazyStaticinnerClassSingle(){
        if (LazyHolder.INSTANCE != null){
            throw  new RuntimeException("不允许非法访问");
        }
    };

    private static  LazyStaticinnerClassSingle getInstance(){
        return LazyHolder.INSTANCE;
    }
    private static  class LazyHolder{
        private static  final LazyStaticinnerClassSingle
                INSTANCE = new LazyStaticinnerClassSingle();
    }
}

